#!/user/bin/env python3
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# @File : login_bs.py
# @Time : 2022-05-31 09:15
# @Author : mojin
# @Email : 397135766@qq.com
# @Software : PyCharm
#-------------------------------------------------------------------------------

import time
from .login_page import LoginPage
from base.basePage import BasePage

class Login_bs(BasePage):



    def login(self, parameter):
        runtime = time.strftime("%Y%m%d%H%M%S", time.localtime())

        # self.d0.screenrecord_start(screenrecord_name,doc='开始录屏……')  # pip3 install -U "uiautomator2[image]" -i https://pypi.doubanio.com/simple
        Package_name = "com.gsx.tiku"

        self.click_element(*LoginPage.tv_agree, doc='点击切换为密码登录')
        if self.is_element_exist_bs(*LoginPage.ShanYanOneKey,doc='判断其他登录方式是否存在'):
            self.click_element(*LoginPage.ShanYanOneKey, doc='其他登录方式存在,切换为其他方式登录')
        self.click_element(*LoginPage.tv_login_pwd,doc='点击切换为密码登录')
        self.send_keys(*LoginPage.LoginID,value=parameter['id'],doc='输入用户id账户')

        self.send_keys(*LoginPage.LoginPWD, value=parameter['pwd'], doc='输入用户登录密码')
        self.click_element(*LoginPage.iv_select,  doc='勾选用户协议')
        self.click_element(*LoginPage.bt_login, doc='点击登录')
        while True:
            if self.is_element_exist_bs(*LoginPage.bt_login, doc='点击登录'):
                self.click_element(*LoginPage.bt_login, doc='点击登录')
                time.sleep(1)
            elif self.is_element_exist_bs(*LoginPage.tvName, doc='点击我的'):
                break


        self.click_element(*LoginPage.tvName, doc='点击我的')






    # def agree(self):
    #     self.click_element(*LoginPage.agree_btn, doc='同意协议')
    #
    # def login(self, user, password):
    #     # with allure.step("同意协议"):
    #     #     self.agree()
    #     self.click_element(*LoginPage.mine_btn, doc='我的页面，点击切换到我的页面-我的按钮')
    #     self.click_element(*LoginPage.login_btn, doc='我的页面，点击登录')
    #     self.click_element(*LoginPage.Confirm_pop_up, doc='点击确认弹框')
    #
    #     self.click_element(*LoginPage.password_login_btn, doc='我的_登录页面_切换到用户密码登录')
    #     self.send_keys(*LoginPage.username_input, value=user, doc='我的_账号密码登录页面，输入账号:{}'.format(user))
    #     self.send_keys(*LoginPage.password_input, value=password, doc='我的_账号密码登录页面，输入密码:{}'.format(password))
    #     self.click_element(*LoginPage.login_submit_btn, doc='我的_账号密码登录页面_点击提交登录')
    #
    # def home_swipe(self):
    #     self.agree()
    #     time.sleep(2)
    #     self.is_element_exist(*LoginPage.discover_search_box, doc="发现")
    #     self.swipe_to_up(doc="首页")
    #
    # def get_username(self):
    #     return self.get_text(*LoginPage.login_btn, doc="获取用户名")

